package com.scu.qingshi.infrastructure.dao.po;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

/**
 * <p>
 * 
 * </p>
 *
 * @author 青时
 * @since 2022-03-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="User对象", description="")
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class User implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "user_id", type = IdType.AUTO)
    private Integer userId;

    private String phone;

    private String openId;

    private String email;

    private Date creteTime;

    private Date modifyTime;

    private String status;

    private String creditNo;

    private String name;

    @ApiModelProperty(value = "密码")
    private String password;


    public void join(String newOpenId) {
        if ("未加入社团".equals(openId)){
            openId = newOpenId;
        }else if (!openId.contains(newOpenId)){
            openId+="-"+newOpenId;
        }
    }

    @Override
    public String toString(){
        JSONObject object = new JSONObject();
        object.putOnce("姓名",name)
                .putOnce("邮箱",email)
                .putOnce("电话",phone)
                .putOnce("已加入社团编码",openId);
        return object.toString();
    }
}
